package com.higgins.eventtracking.client.health.fundamentals;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.higgins.eventtracking.client.health.components.BodyChartListBox;
import com.higgins.eventtracking.client.health.components.BodyMeasurementsChartListBox;
import com.higgins.eventtracking.client.health.components.GenericChartPanel;
import com.higgins.eventtracking.client.health.components.HealthOverviewChartListBox;
import com.higgins.eventtracking.client.health.secondary.BodyChart;

public class BodyChartPanel extends GenericChartPanel	{
	private BodyChartListBox chartListBox = new BodyChartListBox();
	private BodyMeasurementsChartListBox measurementsListBox = new BodyMeasurementsChartListBox();
	private BodyChart annotationChart = new BodyChart();

	public BodyChartPanel()	{
	    HorizontalPanel panel = new HorizontalPanel();
		panel.add(chartListBox);
		panel.add(measurementsListBox);
		add(panel);
        add(annotationChart);
        annotationChart.execute("Squats", false);
		chartListBox.addChangeHandler(new ChangeHandler()  {
			@Override
			public void onChange(ChangeEvent event) {
				int selectedIndex = chartListBox.getSelectedIndex();
				String chartName = chartListBox.getItemText(selectedIndex);
				annotationChart.execute(chartName, false);
			}  });
		measurementsListBox.addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                int selectedIndex = measurementsListBox.getSelectedIndex();
                String chartName = measurementsListBox.getItemText(selectedIndex);
                annotationChart.execute(chartName, true);
            }
		});
	}
}
